<?php

use think\migration\Migrator;
use think\migration\db\Column;

class UserAddressTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('user_address');
        $table->addColumn('user_id', 'integer', array('limit' => 11, 'comment' => '用户uid'))->addIndex('user_id')
            ->addColumn('receiver_name', 'string', array('limit' => 30, 'comment' => '收货人'))
            ->addColumn('receiver_phone', 'string', array('limit' => 30, 'comment' => '收货人手机号'))
            ->addColumn('province', 'string', array('limit' => 60, 'comment' => '所在省份'))
            ->addColumn('city', 'string', array('limit' => 60, 'comment' => '所在城市'))
            ->addColumn('county', 'string', array('limit' => 60, 'comment' => '所在市区或县'))
            ->addColumn('address', 'string', array('limit' => 255, 'comment' => '详细地址'))
            ->addColumn('is_default', 'boolean', array('limit' => 1, 'default' => 0, 'comment' => '是否为默认地址：1是，0否'))
            ->addTimestamps('create_time','update_time')
            ->addSoftDelete()
            ->create();
    }
}
